package com.framework.boc.admin.sms;

import com.framework.boc.admin.properties.CodeProperties;
import org.apache.commons.lang3.RandomStringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class SmsCodeGenerator {

    @Autowired
    CodeProperties codeProperties;

    public SmsCode generate(String phoneNum) {
        String codeStr = RandomStringUtils.randomNumeric(codeProperties.getSms().getSize());
        return new SmsCode(phoneNum, codeStr, codeProperties.getSms().getExpireSeconds());
    }
}
